package com.hrbu.mp.generator.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Description:
 * @Author: tanyajun
 * @CreateTime: 2021/3/31
 * @Blog: https://tanyajun.top
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //在插入的时候执行
        this.strictInsertFill(metaObject,"createDate", Date.class , new Date());
        this.strictInsertFill(metaObject,"updateDate", Date.class , new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //在更新的时候执行
        this.strictInsertFill(metaObject,"upateDate", Date.class , new Date());
    }
}
